import cv2
import numpy as np

# 读取图像
image = cv2.imread('../temp/image.jpg')
if image is None:
    print('Cannot read image file')
    exit(-1)

# 创建锐化核
kernel = np.array([[0, -1, 0], [-1, 5, -1], [0, -1, 0]], dtype=np.float32)

# 进行锐化滤波
sharpened = cv2.filter2D(image, -1, kernel)

# 显示原始图像和锐化后的图像
cv2.namedWindow('Original Image', cv2.WINDOW_NORMAL)
cv2.namedWindow('Sharpened Image', cv2.WINDOW_NORMAL)
cv2.imshow('Original Image', image)
cv2.imshow('Sharpened Image', sharpened)

cv2.waitKey(0)
cv2.destroyAllWindows()
